package com.ym521.freesnack

import android.app.Activity
import androidx.fragment.app.Fragment
import com.ym521.freesnack.theme.FreeSnackTheme
import com.yxqy.base_model.utils.FreeSnack

/**
 *@author Ym
 *E-mail: 2435970206@qq.com
 *createTime:2024/4/13
 *explain:
 *
 * 格式： toToast+位置+时间
 * 默认主题都是 DARK
 */
/**
 * 以下Activity相关的FreeSnack快捷显示
 */
fun Activity.toToastCenterShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.SHORT, FreeSnack.CENTER, theme)


fun Activity.toToastTopShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.SHORT, FreeSnack.TOP, theme)


fun Activity.toToastBottomShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.SHORT, FreeSnack.BOTTOM, theme)


fun Activity.toToastCenter(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.LONG, FreeSnack.CENTER, theme)


fun Activity.toToastTop(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.LONG, FreeSnack.TOP, theme)


fun Activity.toToastBottom(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) =
    FreeSnack.show(window.decorView, msg, FreeSnackTime.LONG, FreeSnack.BOTTOM, theme)

/**
 * 以下Fragment相关的FreeSnack快捷显示
 */

fun Fragment.toToastCenterShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.SHORT, FreeSnack.CENTER, theme)
    }
}


fun Fragment.toToastTopShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.SHORT, FreeSnack.TOP, theme)
    }
}


fun Fragment.toToastBottomShort(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.SHORT, FreeSnack.BOTTOM, theme)
    }
}


fun Fragment.toToastCenter(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.LONG, FreeSnack.CENTER, theme)
    }
}


fun Fragment.toToastTop(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.LONG, FreeSnack.TOP, theme)
    }
}


fun Fragment.toToastBottom(msg: String, theme: FreeSnackTheme = FreeSnackTheme.DARK) {
    view?.let {
        FreeSnack.show(it, msg, FreeSnackTime.LONG, FreeSnack.BOTTOM, theme)
    }
}
